package com.xiaoyuanbang.sms.listener;

import com.aliyuncs.exceptions.ClientException;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.xiaoyuanbang.common.util.SmsUtil;
import java.util.Map;

/**
 * @Description: 验证码监听
 * @Author: yunche
 * @Date: 2022/4/1
 **/
@Component
@RabbitListener(queues = "change1")
public class Change1Listener {

    private  String sign_name="小毕旅游网";

    private  String template_code="SMS_183796696";

    @Autowired
    private SmsUtil smsUtil;

    @RabbitHandler
    public void sendSms(Map<String,String> message) throws Exception {
        System.out.println("手机号："+message.get("mobile"));
        System.out.println("验证码："+message.get("code"));
        String mobile=message.get("mobile");
        String code=message.get("code");
        System.out.println("手机号："+message.get("mobile"));
        System.out.println("验证码："+message.get("code"));
        smsUtil.sendSms(mobile,template_code,sign_name,"{\"code\":\""+code+"\"}");
    }
}
